<include file="public@header"/>
<style type="text/css">
    .pic-list li {
        margin-bottom: 5px;
    }
</style>
<script type="text/html" id="photos-item-tpl">
    <li id="saved-image{id}">
        <input id="photo-{id}" type="hidden" name="photo_urls[]" value="{filepath}">
        <input class="form-control" id="photo-{id}-name" type="text" name="photo_names[]" value="{name}"
               style="width: 200px;" title="图片名称">
        <img id="photo-{id}-preview" src="{url}" style="height:36px;width: 36px;"
             onclick="imagePreviewDialog(this.src);">
        <a href="javascript:uploadOneImage('图片上传','#photo-{id}');">替换</a>
        <a href="javascript:(function(){$('#saved-image{id}').remove();})();">移除</a>
    </li>
</script>
<script type="text/html" id="files-item-tpl">
    <li id="saved-file{id}">
        <input id="file-{id}" type="hidden" name="file_urls[]" value="{filepath}">
        <input class="form-control" id="file-{id}-name" type="text" name="file_names[]" value="{name}"
               style="width: 200px;" title="文件名称">
        <a id="file-{id}-preview" href="{preview_url}" target="_blank">下载</a>
        <a href="javascript:uploadOne('文件上传','#file-{id}','file');">替换</a>
        <a href="javascript:(function(){$('#saved-file{id}').remove();})();">移除</a>
    </li>
</script>
</head>
<body>

<h1>-任务详情-</h1>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:url('AdminIndex/index')}">任务列表</a></li>
        <li><a href="{:url('AdminIndex/add')}">发布任务</a></li>
        <li class="active"><a href="{:url('AdminIndex/add2')}">批量任务</a></li>
    </ul>




    <form action="{:url('AdminIndex/details')}"  id = "myform" method="post" class="form-horizontal js-ajax-form margin-top-20">
        <div class="row">
            <div class="col-md-9">
                <input type="hidden" name = "task_id" id="task_id" value="{$list.task_id}">
                <table class="table table-bordered">


                        <tr>
                            <th>任务标题</th>
                            <td>
                                <p>{$list.title}</p>

                            </td>
                        </tr>
                        <tr>
                            <th>任务内容</th>
                            <td>
                                <p>{$list.task_content}</p>
                            </td>
                        </tr>
                        <tr>
                            <th>发布人</th>
                            <td>
                                <p>{$list.user_nickname}--{$list.publisher}</p>
                            </td>
                        </tr>
                        <tr>
                        <th>
                            <label>任务种类</label>
                        </th>
                        <td>
                            <if condition = "$list.type eq 0">  通知
                                    <elseif condition = "$list.type eq 1">  市场  </elseif>
                                    <elseif condition = "$list.type eq 2">  网运  </elseif>
                                    <elseif condition = "$list.type eq 3">  人事  </elseif>
                            </if>
                        </td>
                    </tr>
                        <tr>
                            <th>
                                <label>任务标签</label>
                            </th>
                            <td>
                                <if condition = "$list.tag eq 0">通知类无需回复
                                    <elseif condition = "$list.tag eq 1">处理人需回复内容</elseif>
                                    <elseif condition = "$list.tag eq 2">处理人需回复内容和附件</elseif>
                                </if>
                            </td>
                        </tr>

                        <tr>
                            <th>
                                <label>发布时间</label>
                            </th>
                            <td>
                                <p>{$list.creat_time}</p>
                            </td>
                        </tr>

                        <tr>
                            <th>
                                <label>截止时间</label>
                            </th>
                            <td>
                                <p>{$list.deadline}</p>
                            </td>
                        </tr>
                        <if condition="!empty($file_names)">
                        <tr>
                            <th>
                                <label>附件详情</label>
                            </th>


                            <td>
                                <foreach name="file_names" item="vo">
                                <p>{$vo.name}</p>
                                <a id="file-video-preview" href="{:cmf_get_file_download_url($vo.url)}"
                                   target="_blank">下载</a>
                            </foreach>
                            </td>
                        </tr>
                        </if>
                </table>
                <div class="well form-inline margin-top-20">
                    <if condition="!empty($authority)">
                        <button class="btn btn-xs btn-danger js-ajax-submit" type="submit" data-action="{:url('AdminIndex/delete_detail',array('task_id' => $list.task_id))}">批量删除</button>
                    </if>
                    <a class="btn btn-xs btn-primary" id="daochu" onclick="submitexplode()">{:lang('导出清单')}</a>
                    <a class="btn btn-xs btn-primary" id="photo" onclick="submitphoto()">{:lang('导出照片')}</a>
                    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
                    <input type="text" class="form-control" name="keyword" style="width: 200px;"
                           value="{$keyword|default=''}" placeholder="请输入关键字...">
                    <select name = "filter" >
                        <option value="0">按处理人</option>
                        <option value="1" >按备注</option>
                        <option value="2" >按时间</option>

                    </select>
                    <input type="submit" class="btn btn-xs btn-primary" value="搜索"/>
                    <a class="btn btn-xs btn-danger" href="{:url('AdminIndex/details',array('task_id' => $list.task_id))}">清空</a>
                    </div>


                <table class="table table-hover table-bordered table-list">
                    <thead>
                    <tr>
                        <th width="50" style="text-align: center">

                            <input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x"></th>

                        <th>处理人</th>
                        <th width="200">任务状态
                            <select onchange = "submitForm()" name = "finished" id = "select8">
                        <option value="0">全部</option>
                        <option value="1" >未读</option>
                        <option value="2" >已读未处理</option>
                        <option value="3" >已处理</option>

                    </select>
                        </th>
                        <th>备注</th>
                        <th>回复内容</th>
                        <th>附件</th>
                        <th>完成时间</th>
                        <th width="50">操作</th>
                    </tr>
                    </thead>
                    <foreach name="receive" item="vo">

                        <tr>

                            <td style="text-align: center"><input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]" value={$vo.receive_id}></td>
                            <td>
                                {$vo.user_nickname}--{$vo.receiver}
                            </td>
                            <td>
                                <if condition = "$vo.finished eq 1">  未读
                                    <elseif condition = "$vo.finished  eq 2">  已读未处理  </elseif>
                                    <elseif condition = "$vo.finished  eq 3">  已处理  </elseif>
                                </if>
                            </td>
                            <td>
                                {$vo.remarks}
                            </td>
                            <td>
                                {$vo.back_content}
                            </td>
                            <td>
                                <php>$photo = json_decode($vo['file_names'],true);</php>
                                <ul id="photos" class="pic-list list-unstyled form-inline">
                                    <notempty name="photo">
                                        <foreach name="photo" item="vo1">
                                            <php>$img_url=cmf_get_image_preview_url($vo1['url']);</php>
                                            <img id="photo-{$key}-preview"
                                                 src="{:cmf_get_image_preview_url($vo1['url'])}"
                                                 style="height:36px;width: 36px;"
                                                 onclick="parent.imagePreviewDialog(this.src);">

                                        </foreach>
                                    </notempty>
                                </ul>
                            </td>
                            <td>
                                {$vo.single_finish_time}
                            </td>
                            <td>
                                <if condition="!empty($authority)">
                                <a class="btn btn-xs btn-danger js-ajax-delete"
                                   href="{:url('AdminIndex/delete_detail',array('ids' => $vo['receive_id'],'task_id' => $list.task_id))}">{:lang('DELETE')}</a>
                                    <a class="btn btn-xs btn-primary" id="edit" href="{:url('AdminIndex/edit_detail',array('ids' => $vo['receive_id'],'task_id' => $list.task_id))}">编辑</a>
                                </if>

                            </td>
                        </tr>
                    </foreach>

                    </table>

                </div>
        </div>
    </form>


</div>

<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
<script type="text/javascript">
    //编辑器路径定义
    var editorURL = GV.WEB_ROOT;
</script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript">
    $("#select8").val("{$finished}")
    $(function () {

        editorcontent = new baidu.editor.ui.Editor();
        editorcontent.render('content');
        try {
            editorcontent.sync();
        } catch (err) {
        }

        $('.btn-cancel-thumbnail').click(function () {
            $('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
            $('#thumbnail').val('');
        });

    });

    function doSelectCategory() {
        var selectedCategoriesId = $('#js-categories-id-input').val();
        openIframeLayer("{:url('AdminCategory/select')}?ids=" + selectedCategoriesId, '请选择分类', {
            area: ['700px', '400px'],
            btn: ['确定', '取消'],
            yes: function (index, layero) {
                //do something

                var iframeWin          = window[layero.find('iframe')[0]['name']];
                var selectedCategories = iframeWin.confirm();
                if (selectedCategories.selectedCategoriesId.length == 0) {
                    layer.msg('请选择分类');
                    return;
                }
                $('#js-categories-id-input').val(selectedCategories.selectedCategoriesId.join(','));
                $('#js-categories-name-input').val(selectedCategories.selectedCategoriesName.join(' '));
                //console.log(layer.getFrameIndex(index));
                layer.close(index); //如果设定了yes回调，需进行手工关闭
            }
        });
    }

    // $('#daochu').click(function () {
    //     if ($('#addtime').val() == ''){
    //         layer.msg('请选择时间范围', {time : 1000});
    //         return false;
    //     }
    //     var url= "{:url('explode_post')}"+'?addtime='+$('#addtime').val()+'&order_num='+$('#order_num').val()+'&user_name='+$("#user_name").val()+"&addr_name="+$("#addr_name").val()+'&goods_type='+$("#goods_type").val()+"&order_status="+$("#order_status").val();
    //     $('#daochu').attr('href',url);
    // })

    function submitForm(){
        var form = document.getElementById("myform");
        form.action = "{:url('AdminIndex/details')}" + "&task_id=" + document.getElementById("task_id").value;
        form.submit();
    }
    function submitexplode(){
        var form = document.getElementById("myform");
        form.action = "{:url('AdminIndex/explode_post')}" + "&task_id=" + document.getElementById("task_id").value;
        form.submit();
    }
    function submitphoto(){
        var form = document.getElementById("myform");
        form.action = "{:url('AdminIndex/export')}" + "&task_id=" + document.getElementById("task_id").value;
        // $('#daochu').attr('href',url)
        form.submit();
    }



</script>
</body>
</html>